$(function () {
  const form = layui.form
  // 数据回填
  function renderEdit() {
    let id = new URLSearchParams(location.search).get('id');
    $.ajax({
      url: 'admin/users/' + id,
      success(res) {
        console.log(res)
        form.val('edit-form', res.data)
      }
    })
  }
  renderEdit()


  $('form').on('submit', function (e) {
    e.preventDefault()
    let data = $(this).serialize()
    $.ajax({
      url: 'admin/users',
      type: 'PUT',
      data,
      success(res) {
        layer.msg(res.message)
      }
    })

  })

})